<template>
  <view class="step-wrapper">
    <view v-for="(step, index) in steps" :key="step.key" :class="step.key === current ? 'step checked' : 'step'">
      <view class="left">
        <view class="circle">
          <image class="icon" :src="stitchingURL(step.key === current ? 'icons/circle-not-disabled' : 'icons/circle-disabled')" />
        </view>
        <view v-if="index < (steps.length - 1)" class="line"></view>
      </view>
      <view class="right">
        <view class="field" v-for="field in fields.filter(v => !!step[v])" :key="field">
          <text class="txt">{{ step[field] || '' }}</text>
        </view>
      </view>
    </view>
  </view>
</template>
<script setup>
  import { stitchingURL } from '@/common/util';

  defineProps({
    steps: {
      type: Array,
      default: () => []
    },
    current: "",
    fields: {
      type: Array,
      default: () => []
    },
  });
  

</script>
<style lang="scss" scoped>
  .step-wrapper {
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
    flex-direction: column;
    padding-left: 50upx;
    .step {
      position: relative;
      padding-bottom: 30upx;
      .left {
        position: absolute;
        top: 0;
        left: 0;
        bottom: 0;
        width: 30upx;
        z-index: 1;
        .circle {
          position: absolute;
          z-index: 3;
          top: 4upx;
          left: 0;
          width: 30upx;
          height: 30upx;
          .icon {
            width: 30upx;
            height: 30upx;
          }
        }
        .line {
          position: absolute;
          top: 0upx;
          left: 14upx;
          width: 2upx;
          bottom: -4upx;
          z-index: 2;
          border-radius: 2upx;
          background: #EAEAEA;
        }
      }
      .right {
        margin-left: 84upx;
        .field {
          .txt {
            color: #999;
            font-size: 26upx;
            font-style: normal;
            font-weight: 400;
            line-height: normal;
            line-height: 36upx;
          }
        }
        &:first-child {
          .txt {
            font-size: 32upx;
          }
        }
      }
      &.checked {
        .right {
          .field {
            .txt {
              color: #1f1f1f;
            }
            &:first-child {
              .txt {
                color: #DA2018;
              }
            }
          }
        }
      }
      &:first-child {
        .left {
          .line {
            top: 10upx;
          }
        }
      }
    }
  }
</style>